package com.qiqijuice.sales;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Order {
	public static enum OrderState  {
		ONHOLD,
		PAYED,
		REMOVED
	};
	
	private Date date;
	private String memo;
	private OrderState state;
	
	private String customerName;
	private String customerPhone;
	private String customerAddress;
	
	List<OrderItem> orderItems;

	public Order() {
		this.date = new Date();
		this.state = OrderState.ONHOLD;
		this.memo = "Default order description";
		
		customerName = "N/A";
		customerPhone= "N/A";
		customerAddress = "N/A";
		orderItems = new ArrayList<OrderItem>();
	}
	
	public Order(Date date, OrderState state,
			String memo, String customerName, String customerPhone,
			String customerAddress, List<OrderItem> orderItems) {
		
		this.date = date;
		this.state = state;
		this.memo = memo;
		this.customerName = customerName;
		this.customerPhone = customerPhone;
		this.customerAddress = customerAddress;
		this.orderItems = orderItems;
	}

	public String getMemo() {
		return memo;
	}

	public void setMemo(String memo) {
		this.memo = memo;
	}


	public OrderState getState() {
		return state;
	}

	public void setState(OrderState state) {
		this.state = state;
	}

	public String getCustomerName() {
		return customerName;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	public String getCustomerPhone() {
		return customerPhone;
	}

	public void setCustomerPhone(String customerPhone) {
		this.customerPhone = customerPhone;
	}

	public String getCustomerAddress() {
		return customerAddress;
	}

	public void setCustomerAddress(String customerAddress) {
		this.customerAddress = customerAddress;
	}

	public Date getDate() {
		return date;
	}
	
	public void addOrderItem(OrderItem oi) {
		orderItems.add(oi);
	}
	
	public void deleteOrderItem(OrderItem oi) {
		orderItems.remove(oi);
	}
	
	public void deleteOrderItem(int idx) {
		orderItems.remove(idx);
	}
	
	public OrderItem[] getOrderItems() {
		return orderItems.toArray(new OrderItem[0]);
	}
}
